<?php


namespace App\HttpController\Mp1;


use App\Exceptions\BizException;
use Base\BaseController;
use Base\BaseException;
use App\Bizs\Mp1\UserBiz;

class User extends BaseController
{
    /**
     * @Apiname 小程序登录
     *
     * @Param jscode {"type": "string", "require": true, "desc": "小程序登录code"}
     *
     * @throws BizException
     * @throws BaseException
     */
    public function mpLogin()
    {
        $res = (new UserBiz())->mpLogin($this->params);
        $this->returnJson(
            $res['data'],
            $res['msg'],
            $res['code']
        );
    }

    /**
     * @Apiname 发送验证码
     *
     * @Param mobile {"type": "string", "require": true, "desc": "手机号"}
     * @Param temp_token {"type": "string", "require": true, "desc": "临时token"}
     */
    public function sendVCode()
    {

    }

    /**
     * @Apiname 绑定手机号
     *
     * @Param mobile {"type": "string", "require": true, "desc": "手机号"}
     * @Param temp_token {"type": "string", "require": true, "desc": "临时token"}
     * @Param vcode {"type": "string", "require": true, "desc": "验证码"}
     */
    public function bindPhone()
    {

    }

    /**
     * @Apiname 获取用户信息
     */
    public function getUserInfo()
    {
        $this->returnJson(
            (new UserBiz())->getUserInfo($this->uid)
        );
    }

    /**
     * @Apiname 设置用户信息
     * @Param nickname {"type": "string", "desc": "昵称"}
     * @Param icon {"type": "string", "desc": "头像"}
     * @Param sina {"type": "string", "desc": "个签"}
     * @Param gender {"type": "string", "desc": "性别"}
     * @Param city {"type": "int", "desc": "城市"}
     * @Param province {"type": "int", "desc": "省"}
     * @Param mobile {"type": "string", "desc": "联系电话"}
     * @Param weixin {"type": "string", "desc": "微信号"}
     * @throws BizException
     */
    public function setUserInfo()
    {
        $this->returnJson(
            (new UserBiz())->setUserInfo($this->params, $this->uid)
        );
    }

    public function getUnreadMessageCount()
    {
        $this->returnJson(
            (new UserBiz())->getUnreadMessageCount($this->uid)
        );
    }

    /**
     * @Apiname 获取指定用户详情
     * @Param uid {"type": "int", "desc": "用户id"}
     */
    public function getUserDetail()
    {
        $this->returnJson(
            (new UserBiz())->getUserDetail($this->params['uid'])
        );
    }
}
